package com.gxa.eurekribbon.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.Map;

@RestController
public class RestTemplateController {
    @Resource
    private RestTemplate restTemplate;

    @RequestMapping(value = "/show",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map show(String name) {

        // 这里调用的是client模块EurekaclientApplication中的show请求路径
        // 需要注意的是EUREKA-CLIENT是server中加载的客户端名字，默认全部大写
        Map forObject = restTemplate.getForObject("http://EUREKA-CLIENT/show?name=" + name, Map.class);
        return forObject;
    }
}
